#ifndef ENV_H
#define ENV_H

#include <QtCore>
#include "batchnetworkaccessmanager.h"
#include "mainwindow.h"
#include "pages.h"
////#include "t_box_api_backend.h"

class Env;
extern Env *g_Env;

class Env : public QObject
{
	Q_OBJECT
public:
	Env();
	~Env();
	void settingsLoad();
	void settingsSave();
	void youtubeLogin();
	void showMessage(QString a_msg);
    BatchNetworkAccessManager *nam;
	MainWindow *mainWindow;
	T_Page1 *page1;
    ////T_Box_Api_BackendFactory f_bef;

	Q_PROPERTY(QString youtube_login_id READ get_youtube_login_id WRITE set_youtube_login_id)
	QString youtube_login_id;
	QString get_youtube_login_id() { return youtube_login_id; }
	void set_youtube_login_id(QString a) { youtube_login_id = a; }

	Q_PROPERTY(QString youtube_password READ get_youtube_password WRITE set_youtube_password)
	QString youtube_password;
	QString get_youtube_password() { return youtube_password; }
	void set_youtube_password(QString a) { youtube_password = a; }

	Q_PROPERTY(QString youtube_devl_key READ get_youtube_devl_key WRITE set_youtube_devl_key)
	QString youtube_devl_key;
	QString get_youtube_devl_key() { return youtube_devl_key; }
	void set_youtube_devl_key(QString a) { youtube_devl_key = a; }

	Q_PROPERTY(QString youtube_auth_key READ get_youtube_auth_key WRITE set_youtube_auth_key)
	QString youtube_auth_key;
	QString get_youtube_auth_key() { return youtube_auth_key; }
	void set_youtube_auth_key(QString a) { youtube_auth_key = a; }

protected:
	QSettings *m_settings;
	QString settingsFileName();

	friend QDebug operator<< (QDebug d, const Env *model)
	{
		operator <<(d, (*model));
		return d;
	}

	friend QDebug operator<< (QDebug d, const Env &model)
	{
		d << "{Env:";
		d << "\n";
		for(int i=0; i<model.metaObject()->propertyCount(); i++)
		{
			QMetaProperty v_prop = model.metaObject()->property(i);
			if(strcmp(v_prop.name(), "objectName")==0) continue;
			d << QString("<%1>").arg(v_prop.name()) << model.property(v_prop.name());
			d << "\n";
		}
		d << "}";
		return d;
	}

};




#endif // ENV_H
